package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.constant.KeyConsts;
import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.manager.api.IQuerySceneInstService;
import com.iwhalecloud.bss.kite.manager.enums.ActionType;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.manager.inst.KiteProdInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;
import com.ztesoft.bss.common.util.ContextUtil;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;
import java.util.Objects;

/**
 * <Description> <br>
 *  装机详细地址描述
 * @author cheng.leizhen01<br>
 * @version 1.0<br>
 * @taskId <br>
 * @CreateDate 2021年3月14日 <br>
 * @since R9.0<br>
 * @see com.iwhalecloud.bss.kite.cucc.service.attr.handler <br>
 */

public class LocalInstallDetailAddressAttrHandler extends AbstractAttrHandler<KiteInst, AttrData> {
    @Autowired
    IQuerySceneInstService querySceneInstService;

    @Override
    public void before(KiteAttr attr, KiteInst inst, String value, AttrData data) {
        super.before(attr, inst, value, data);
        Map<String, Object> extParams = ContextUtil.getLoginInfo().getUserInfo().getExtParams();
        if((Objects.nonNull(extParams) && extParams.containsKey("nodeCode"))){
            String nodeCode = extParams.get("nodeCode").toString();
            if(KiteStringUtils.equalsAny(nodeCode,"OrderSigned")) {
                // 装机地址
                KiteAttr InstallAddressAttr = inst.getAttr("2_0000209");
                if (Objects.nonNull(InstallAddressAttr)) {
                    InstallAddressAttr.setIsEdit(KeyConsts.IFTRUE_F);
                }
                // 接入端口类型
                KiteAttr accessPortTypeAttr = inst.getAttr("2_0000064");
                if (Objects.nonNull(accessPortTypeAttr)) {
                    accessPortTypeAttr.setIsEdit(KeyConsts.IFTRUE_F);
                }
                // Z端装机地址
                KiteAttr zInstallAddressAttr = inst.getAttr("2_0000105");
                if (Objects.nonNull(zInstallAddressAttr)) {
                    zInstallAddressAttr.setIsEdit(KeyConsts.IFTRUE_F);
                }
                // 接口类型（A端）
                KiteAttr accessPortATypeAttr = inst.getAttr("2_0000008");
                if (Objects.nonNull(accessPortATypeAttr)) {
                    accessPortATypeAttr.setIsEdit(KeyConsts.IFTRUE_F);
                }
                // 接口类型（Z端）
                KiteAttr accessPortZTypeAttr = inst.getAttr("2_0000010");
                if (Objects.nonNull(accessPortZTypeAttr)) {
                    accessPortZTypeAttr.setIsEdit(KeyConsts.IFTRUE_F);
                }
                attr.setIsEdit(KeyConsts.IFTRUE_F);
            }

        }

    }
}
